<!DOCTYPE html>
<html>
<head>
    <title>用户批量导入</title>
    <script src="${ctx}/static/admin/layui/layui.js"></script>
    <script src="${ctx}/static/admin/js/common.js"></script>
    <script type="text/javascript">
        var table;
        layui.use(['jquery', 'upload'], function () {
            var $ = layui.jquery
                , upload = layui.upload;
            var type=0;
            //普通excel上传
            var msg;
            upload.render({
                elem: '#houseMaps'
                , url: "${ctx}/sys_admin/mineservice/importExcel?moduleid=${moduleid!}"
                , auto: false
                , accept: 'file'
                , exts: 'xls'
                //,multiple: true
                , bindAction: '#ajaxFileUpload'
                ,data: {
                    "type":type
                }
                ,choose:function (obj) {
                }
                ,before: function(obj){
                    this.data.type=$('#type').val()
                    msg = parent.layer.msg('正在处理中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,time: 0});
                }
                , done: function (result) {
                    parent.layer.close(msg);
                    if (result.success) {
                        //parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else {
                        parent.layer.alert(result.msg);
                    }
                }
            });
        });

        function downloadsmodel() {
            downFileByIframe('${ctx}/sys_admin/mineservice/exportExcel?moduleid=${moduleid!}&tablename=${tablename!}&type=0');
            return false;
        }

        function chooseType() {
            layui.use(['jquery'], function () {
                $ = jQuery = layui.$;
                layer.confirm('新增或者覆盖？', {
                    btn: ['新增', '覆盖'] //按钮
                }, function () {
                    $('#type').val(0)
                    $('#ajaxFileUpload').click();
                }, function () {
                    $('#type').val(1)
                    $('#ajaxFileUpload').click();
                });
            });
        }

    </script>
</head>

<body>
<form>
    <fieldset>
        <legend>导入信息</legend>
        <table class="table" style="width: 100%;">
            <tr>
                <th>excel模版:</th>
                <td><a href="javascript:downloadsmodel()">下载模版</a></td>
            </tr>
            <tr>
                <th>excel文件:</th>
                <td><input type="file" id="houseMaps" name="houseMaps"/><input type="hidden" id="ajaxFileUpload"><input onclick="chooseType()" type="button" value="上传"
                                                                               /></td>
            </tr>
        </table>
    </fieldset>
    <input type="hidden" id="type" value="0">
</form>
</body>
</html>